home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / FWIconSh.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  5.9 KB  |  205 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWIconSh.cpp
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef FWICONSH_H
  13. #include "FWIconSh.h"
  14. #endif
  15.  
  16. #ifndef FWGC_H
  17. #include "FWGC.h"
  18. #endif
  19.  
  20. #ifndef SLRENDER_H
  21. #include "SLRender.h"
  22. #endif
  23.  
  24. // ----- Foundation Includes -----
  25.  
  26. #ifndef FWSTREAM_H
  27. #include "FWStream.h"
  28. #endif
  29.  
  30. //========================================================================================
  31. // File scope definitions
  32. //========================================================================================
  33.  
  34. #ifdef FW_BUILD_MAC
  35. #pragma segment FWGraphx_IconShape
  36. #endif
  37.  
  38. //========================================================================================
  39. //    class FW_CIconShape
  40. //========================================================================================
  41.  
  42. FW_DEFINE_AUTO(FW_CIconShape)
  43. FW_DEFINE_CLASS_M1(FW_CIconShape, FW_CBoundedShape)
  44.  
  45. // This class is archivable, but we provide the archiving implementation in a separate
  46. // translation unit in order to enable deadstripping of the archiving-related code
  47. // in parts that do not use archiving with this class.
  48.  
  49. //----------------------------------------------------------------------------------------
  50. //    FW_CIconShape::FW_CIconShape
  51. //----------------------------------------------------------------------------------------
  52.  
  53. FW_CIconShape::FW_CIconShape(const FW_CIcon& Icon,
  54.                              const FW_CRect& rect,
  55.                              FW_RenderIconTransform transform,
  56.                              FW_RenderIconAlignment alignment) :
  57.     FW_CBoundedShape(rect, FW_kFill, FW_kNormalInk, FW_kNormalStyle, FW_kNormalFont),
  58.     fIcon(Icon),
  59.     fTransform(transform),
  60.     fAlignment(alignment)
  61. {
  62.     FW_END_CONSTRUCTOR
  63. }
  64.  
  65. //----------------------------------------------------------------------------------------
  66. //    FW_CIconShape::FW_CIconShape
  67. //----------------------------------------------------------------------------------------
  68.  
  69. FW_CIconShape::FW_CIconShape(const FW_CIconShape& other) :
  70.     FW_CBoundedShape(other),
  71.     fIcon(other.fIcon),
  72.     fTransform(other.fTransform),
  73.     fAlignment(other.fAlignment)
  74. {
  75.     FW_END_CONSTRUCTOR
  76. }
  77.  
  78. //----------------------------------------------------------------------------------------
  79. //    FW_CIconShape::FW_CIconShape
  80. //----------------------------------------------------------------------------------------
  81.  
  82. FW_CIconShape::FW_CIconShape(FW_CReadableStream& stream) :
  83.     FW_CBoundedShape(stream)
  84. {
  85.     stream >> fIcon;
  86.     stream >> fTransform;
  87.     stream >> fAlignment;
  88.  
  89.     FW_END_CONSTRUCTOR
  90. }
  91.  
  92. //----------------------------------------------------------------------------------------
  93. //    FW_CIconShape::~FW_CIconShape
  94. //----------------------------------------------------------------------------------------
  95.  
  96. FW_CIconShape::~FW_CIconShape()
  97. {
  98.     FW_START_DESTRUCTOR
  99. }
  100.  
  101. //----------------------------------------------------------------------------------------
  102. //    FW_CIconShape::operator=
  103. //----------------------------------------------------------------------------------------
  104.  
  105. FW_CIconShape& FW_CIconShape::operator=(const FW_CIconShape& other)
  106. {
  107.     FW_CBoundedShape::operator=(other);
  108.  
  109.     fIcon = other.fIcon;
  110.     fTransform = other.fTransform;
  111.     fAlignment = other.fAlignment;
  112.  
  113.     return *this;
  114. }
  115.  
  116. //----------------------------------------------------------------------------------------
  117. //    FW_CIconShape::Render
  118. //----------------------------------------------------------------------------------------
  119.  
  120. void FW_CIconShape::Render(FW_CGraphicContext& gc) const
  121. {
  122.     FW_PrivRenderIcon(gc.GetEnvironment(),
  123.         gc,
  124.         fIcon,
  125.         fRect,
  126.         fTransform,
  127.         fAlignment,
  128.         GetRenderVerb());
  129.     FW_FailOnEvError(gc.GetEnvironment());
  130. }
  131.  
  132.  
  133. //----------------------------------------------------------------------------------------
  134. //    FW_CIconShape::Copy
  135. //----------------------------------------------------------------------------------------
  136.  
  137. FW_CShape* FW_CIconShape::Copy() const
  138. {
  139.     return FW_NEW(FW_CIconShape, (*this));
  140. }
  141.  
  142. //----------------------------------------------------------------------------------------
  143. //    FW_CIconShape::Flatten
  144. //----------------------------------------------------------------------------------------
  145.  
  146. void FW_CIconShape::Flatten(FW_CWritableStream& stream) const
  147. {
  148.     FW_CBoundedShape::Flatten(stream);
  149.     
  150.     stream << fIcon;
  151.     stream << fTransform;
  152.     stream << fAlignment;
  153. }
  154.  
  155. //----------------------------------------------------------------------------------------
  156. //    FW_CIconShape::RenderIcon
  157. //----------------------------------------------------------------------------------------
  158.  
  159. void FW_CIconShape::RenderIcon(FW_CGraphicContext& gc,
  160.                                const FW_CIcon& icon,
  161.                                const FW_CRect& rect,
  162.                                FW_RenderIconTransform transform,
  163.                                FW_RenderIconAlignment alignment)
  164. {
  165.     FW_PrivRenderIcon(gc.GetEnvironment(),
  166.         gc,
  167.         icon,
  168.         rect,
  169.         transform,
  170.         alignment,
  171.         FW_kFill);
  172.     FW_FailOnEvError(gc.GetEnvironment());
  173. }
  174.  
  175. //----------------------------------------------------------------------------------------
  176. //    FW_CIconShape::GetGeometry
  177. //----------------------------------------------------------------------------------------
  178.  
  179. void FW_CIconShape::GetGeometry(FW_CIcon& icon,
  180.                                 FW_CRect& bounds,
  181.                                 FW_RenderIconTransform& transform,
  182.                                 FW_RenderIconAlignment& alignment) const
  183. {
  184.     icon = fIcon;
  185.     transform = fTransform;
  186.     alignment = fAlignment;
  187.     bounds = fRect;
  188. }
  189.  
  190. //----------------------------------------------------------------------------------------
  191. //    FW_CIconShape::SetGeometry
  192. //----------------------------------------------------------------------------------------
  193.  
  194. void FW_CIconShape::SetGeometry(const FW_CIcon& icon,
  195.                                 const FW_CRect& bounds,
  196.                                 FW_RenderIconTransform transform,
  197.                                 FW_RenderIconAlignment alignment)
  198. {
  199.     fIcon = icon;
  200.     fTransform = transform;
  201.     fAlignment = alignment;
  202.     fRect = bounds;
  203. }
  204.  
  205.